#ifndef H_ANIMATED_DRAWABLE
#define H_ANIMATED_DRAWABLE

#include "drawable.h"
#include "sprite.h"
#include "timer.h"

class AnimatedDrawable : public Drawable {
   // This will be one sprite which returns the correct
   // frame every time a call to iter is done
   // In this case the sprite is a sprite chart
   // and Rect* rect is a vector of rects
   private:
      unsigned int current;
      UINT start;
   public:
 AnimatedDrawable  ( Sprite* _sprite  ) :  Drawable ( _sprite) {
   pDebug( this << " AnimatedDrawable (" << "Sprite* _sprite =" << &_sprite   << ")")
 	 current = 0;
	 start=0;
      }

virtual void advance (  )  {
   pDebug( this << " virtual void advance("   << ")")
 
	 AnimatedSprite* pSprite = (AnimatedSprite*) getSprite();
	 UINT frames = pSprite->getFrames();

	 current++;
	 if ( current == frames ) current = 0;
      }

virtual Rect* getGeometryRect  (  )  {
   pDebug( this << " virtual Rect* getGeometryRect ("   << ")")
 	 Rect* ret;
	 AnimatedSprite* pSprite = (AnimatedSprite*) getSprite();

	 if ( pSprite == NULL ) return NULL;
	 ret = pSprite->getFrame( current );
	 return ret;
      }
};

#endif
